package com.dlna.ftp;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;


public class PreferenceHelper {

	public static final String KEY_USERNAME= "username";   
	public static final String KEY_PASSWORD= "password";
	public static final String KEY_PORT= "port";
	public static final String KEY_HOST= "host";	
	public static final String KEY_FTPFLODER= "ftpfloder";
    private static SharedPreferences.Editor mEditor = null;
    private static SharedPreferences mdPreferences = null;
    
	public PreferenceHelper(Context context)
	{
	}
    private static SharedPreferences.Editor getEditor(Context paramContext) {
        if (mEditor == null)
            mEditor = PreferenceManager.getDefaultSharedPreferences(paramContext).edit();
        return mEditor;
    }

    private static SharedPreferences getSharedPreferences(Context paramContext) {
        if (mdPreferences == null)
            mdPreferences = PreferenceManager.getDefaultSharedPreferences(paramContext);
        return mdPreferences;
    }
    public static String getUsername(Context context){
        return PreferenceHelper.getSharedPreferences(context).getString(KEY_USERNAME, "");
    }

    public static void setUsername(Context context, String username){
        getEditor(context).putString(KEY_USERNAME, username).commit();
    }
    
    public static String getPassword(Context context){
        return PreferenceHelper.getSharedPreferences(context).getString(KEY_PASSWORD, "");
    }

    public static void setPassword(Context context, String password){
        getEditor(context).putString(KEY_PASSWORD, password).commit();
    }
    public static String getPort(Context context){
        return PreferenceHelper.getSharedPreferences(context).getString(KEY_PORT,"21");
    }

    public static void setPort(Context context, String port){
        getEditor(context).putString(KEY_PASSWORD, port).commit();
    }
    public static String getHost(Context context){
        return PreferenceHelper.getSharedPreferences(context).getString(KEY_HOST, "");
    }

    public static void setHost(Context context, String host){
        getEditor(context).putString(KEY_HOST, host).commit();
    }
    public static String getFtpFloder(Context context){
        return PreferenceHelper.getSharedPreferences(context).getString(KEY_FTPFLODER, "");
    }

    public static void setFtpFloder(Context context, String ftpfloder){
        getEditor(context).putString(KEY_FTPFLODER, ftpfloder).commit();
    }

}
